package com.eason.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HeController {

    @RequestMapping("/hello")
    public String hello(Model model){
        model.addAttribute("msg","SpringMVCAnnotation!");
        return "hello";
    }

    @GetMapping("/add/{a}/{b}")
    public String test1(@PathVariable int a, @PathVariable String b, Model model){
        String res = a + b;
        model.addAttribute("msg","结果1为" + res);
        return "hello";
    }
    @PostMapping("/add/{a}/{b}")
    public String test2(@PathVariable int a,@PathVariable String b,Model model){
        String res = a + b;
        model.addAttribute("msg","结果2为" + res);
        return "hello";
    }
}
